﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using Jacaranda.Model;

namespace Jacaranda.Data
{
    abstract class DataAccess
    {
        public static DataAccess Create()
        {
            if (DataPortal.DatabaseType == DatabaseType.Access)
            {
                return new OleDbDataAccess();
            }
            else if (DataPortal.DatabaseType == DatabaseType.SqlServer)
            {
                return new SqlDataAccess();
            }
            else if (DataPortal.DatabaseType == DatabaseType.SqlServer2000)
            {
                return new Sql2000DataAccess();
            }

            return null;
        }


        public abstract DbConnection CreateDbConnection();

        public abstract DbCommand CreateDbCommand();

        public abstract DbDataAdapter CreateDbDataAdapter();

        public abstract DbCommandBuilder CreateDbCommandBuilder();

        public abstract DbParameter CreateDbParameter();

        public abstract string AssociationTableTimestampColumnName { get; }

        public abstract string CreateParameterizedExpression(string parameterName);

        public abstract void DeleteTableData(string tableName);

        public abstract void DropTable(string tableName);

        public abstract void DropFunction(string functionName);

        public abstract string CreatePagingSelectStatement(ConditionalExpression expression, Type entityType, string fields, SortCriteria sort, SearchPaginationCriteria page);
    }
}
